package com.augurit.wf.common.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.augurit.common.base.dao.BaseDao;
import com.augurit.wf.common.entity.WfActElemPrivDef;

@Repository
public class WfActElemPrivDefDao extends BaseDao<WfActElemPrivDef, Long> {
	/**
	 * 获取某一个流程业务模板下某一个节点对应的页面元素
	 * @param templateId
	 * @param activityName
	 * @return
	 */
	public List<WfActElemPrivDef> getByTemplateAndActivity(Long templateId, String activityName){
		String hql = "from WfActElemPrivDef priv where priv.templateId = ? and priv.activityName = ?";
		List<Object> values = new ArrayList<Object>();
		return this.find(hql, values);
	}
	
	/**
	 * 删除一个业务流程模板下的所有权限配置信息
	 * @param templateId
	 */
	public void deleteElemPrivInTemplate(Long templateId){
		List<WfActElemPrivDef> entities = this.findBy("templateId", templateId);
		if(entities != null && entities.size() > 0){
			for(WfActElemPrivDef entity:entities){
				this.delete(entity);
			}
		}
	}
}